#ifndef __NRF_SPI_H__
#define __NRF_SPI_H__

#include "gpio.h"
#include "spi.h"

#define NRF_CE_GPIO							GPIOB
#define NRF_CSN_GPIO				    GPIOB
#define NRF_IQR_GPIO				    GPIOA

#define NRF_CE_GPIO_PIN				GPIO_PIN_2
#define NRF_CSN_GPIO_PIN		  GPIO_PIN_15
#define NRF_IQR_GPIO_PIN		  GPIO_PIN_4

#define NRF_SPI (hspi1)

#define NRF_CE(x)					HAL_GPIO_WritePin(NRF_CE_GPIO,   NRF_CE_GPIO_PIN,    (GPIO_PinState)(x))
#define NRF_CSN(x)			  HAL_GPIO_WritePin(NRF_CSN_GPIO,  NRF_CSN_GPIO_PIN,   (GPIO_PinState)(x))
#define NRF_IQR						HAL_GPIO_ReadPin(NRF_IQR_GPIO,   NRF_IQR_GPIO_PIN)

void nrfspi_init(void);
uint8_t nrfspi_WriteByte(uint8_t addr, uint8_t order, uint8_t mode);
uint8_t nrfspi_ReadByte(uint8_t addr);
void nrfspi_WriteBuff(uint8_t addr, uint8_t *databuff, uint8_t len, uint8_t cANDd);
void nrfspi_ReadBuff(uint8_t addr, uint8_t *databuff, uint8_t len);


void spi_SetClk(SPI_HandleTypeDef *hspi, uint8_t CPOL, uint8_t CPHA);

#endif

